﻿namespace Carson.DataAccess.PagePlugin
{
    public class SqlServerPagePlugin:IPagePlugin
    {
        public string GetCountString(string preparedSql)
        {
            return string.Format("select count(1) from ({0}) innerq ", preparedSql);
        }

        public string GetLimitString(string preparedSql, int startIndex, int count, string sidx, string sord)
        {
            startIndex = startIndex + 1;
            int endIndex = startIndex + count - 1;
            return string.Format("select * from (select row_number() over(order by {1} {2}) as rowNum,* from ({0})innerq) as t where rowNum between {3} and {4}", preparedSql, sidx, sord, startIndex, endIndex);
        }
    }
}
